import hyRequest from '@/service'
import { LOGIN_TOKEN } from '@/global/constans'
import { localCache } from '@/utils/cache'
// 用户的网络请求

// 查询用户
export function postUserList(queryInfo: any) {
  return hyRequest.post({
    url: '/users/list',
    data: queryInfo,
    headers: {
      Authorization: `Bearer ${localCache.getCache(LOGIN_TOKEN)}`
    }
  })
}

// 删除用户
export function deleteUser(userId: number) {
  return hyRequest.delete({
    url: `/users/${userId}`,
    headers: {
      Authorization: `Bearer ${localCache.getCache(LOGIN_TOKEN)}`
    }
  })
}

// 创建用户
export function createUser(userInfo: any) {
  return hyRequest.post({
    url: '/users',
    data: userInfo,
    headers: {
      Authorization: `Bearer ${localCache.getCache(LOGIN_TOKEN)}`
    }
  })
}

// 修改用户
export function updateUser(userInfo: any, userId: number) {
  return hyRequest.patch({
    url: `/users/${userId}`,
    data: userInfo,
    headers: {
      Authorization: `Bearer ${localCache.getCache(LOGIN_TOKEN)}`
    }
  })
}
